<?php
require_once __DIR__ . "/include_common.php";

use Illuminate\Database\Capsule\Manager;

//$db = new MyDb();
////$db->setDbSource("db_test");
//$users = $db->table("user")->get();
//var_dump($users);
global $GLOBALS_CONFIGS;
if (!isset($GLOBALS_CONFIGS['db']) || !isset($GLOBALS_CONFIGS['db']['default'])) {
    throw new Exception("未设置数据库配置");
}
$db = new Manager();
$db->addConnection($GLOBALS_CONFIGS['db']['default'], 'default');
$db->setAsGlobal();
$db->bootEloquent();
$db->getConnection('default')->transaction(function () use ($db) {
    $db::table("user")->insert([
        'name' => 'wskyygyso',
        'email' => 'wskyygyso@qq.com'
    ]);
});
